import React,{Component,PropTypes} from 'react';
class Counter extends Component {
     constructor(props) {
        super(props)
    }
    incrementIfOdd(){
        console.log(this.props.value);
        if (this.props.value % 2 == 0) {
            this.props.onIncrement();
        }
    }
    inCrementAnsy(){
        console.log(this.props.value)
        setTimeout(() => {
            this.props.onIncrement();
        }, 1000)
    }

    render() {
        const {value, onIncrement, onDecrement} = this.props
        return (<div>
        <p>
            Clicked: {value}times
        {' '}
            <button onClick={onIncrement}>
                +
        </button>
            {' '}
            <button onClick={onDecrement}>
                -
        </button>
            {' '}
            <button onClick={this.incrementIfOdd.bind(this)}>
                Increment if odd
        </button>
            {' '}
            <button onClick={this.inCrementAnsy.bind(this)}>
                Increment async
        </button>
        </p></div>)
    }
}

export default Counter;
